home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / System / ReqToolsLib / Source / reqtools / mem.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-02  |  1.2 KB  |  62 lines

  1.  
  2.     SECTION "text",CODE
  3.  
  4.     INCLUDE "exec/types.i"
  5.     INCLUDE "exec/funcdef.i"
  6.     INCLUDE "exec/memory.i"
  7.     INCLUDE "exec/exec_lib.i"
  8.  
  9.     XDEF        @AllocVecPooled
  10.     XDEF        @FreeVecPooled
  11.  
  12.     XREF        _AsmAllocPooled
  13.     XREF        _AsmFreePooled
  14.  
  15. ;
  16. ; Function to do AllocVecPooled (pool, memsize)
  17. ;                                A0    D0
  18. @AllocVecPooled:
  19.     move.l    a6,-(a7)
  20.     move.l    $4.w,a6
  21.     move.l    a0,d1
  22.     bne.b        .pool
  23.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  24.     jsr        _LVOAllocVec(a6)
  25.     move.l    (a7)+,a6
  26.     rts
  27. .pool:
  28.     addq.l   #4,d0                        ; Get space for tracking
  29.     move.l    d0,-(sp)                    ; Save the size
  30.     jsr        _LVOAllocPooled(a6)    ; Call pool...
  31.     move.l    (sp)+,d1                    ; Get size back...
  32.     tst.l        d0                            ; Check for error
  33.     beq.s        avp_fail                    ; If NULL, failed!
  34.     move.l    d0,a0                        ; Get pointer...
  35.     move.l    d1,(a0)+                    ; Store size
  36.     move.l    a0,d0                        ; Get result
  37. avp_fail:
  38.     move.l    (a7)+,a6
  39.     rts
  40.  
  41. ;
  42. ; Function to do FreeVecPooled (pool, memory)
  43. ;                               A0    A1
  44. @FreeVecPooled:
  45.     move.l    a1,d0
  46.     beq.b        nofree
  47.     move.l    a6,-(a7)
  48.     move.l    $4.w,a6
  49.     move.l    a0,d1
  50.     bne.b        .pool
  51.     jsr        _LVOFreeVec(a6)
  52.     move.l    (a7)+,a6
  53.     rts
  54. .pool:
  55.     move.l    -(a1),d0                    ; Get size / ajust pointer
  56.     jsr        _LVOFreePooled(a6)
  57.     move.l    (a7)+,a6
  58. nofree:
  59.     rts
  60.  
  61.     END
  62.